﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SEO.Business;
using SEO.Entity;

/// <summary>
/// 管理权限组列表
/// </summary>
public partial class webadmin_AdminTypeList : AdminPage
{
    protected int nNum = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    /// <summary>
    /// 权限控制
    /// </summary>
    /// <returns></returns>
    public override long GetNeededFeatures()
    {
        return AdminFEATURE.UserType;
    }


    protected void InitData()
    {
        DataTable dt = new BisAdminInfo().GetAdminTypeList();
        rptAdminType.DataSource = dt;
        rptAdminType.DataBind();
        dt.Dispose();
    }

    
    /// <summary>
    /// 列表绑定
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void rptAdminType_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            //删除信息
            bool result = new BisAdminInfo().DeleteAdimType(Convert.ToInt32(e.CommandArgument));
            Until.Alert(result ? "删除成功！" : "删除失败！");
            InitData();
        }
    }

     /// <summary>
    /// 列表绑定处理
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void rptAdminType_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataTable dt = (DataTable)((Repeater)sender).DataSource;
        Literal ltlEdite=e.Item.FindControl("ltlEdite") as Literal;
        if ((long)dt.Rows[e.Item.ItemIndex]["Features"] == 1)
        {
            ImageButton btnDelete = e.Item.FindControl("btnDelete") as ImageButton;
            btnDelete.Visible = false;
            ltlEdite.Visible=false;
        }else{
            ltlEdite.Text = "<a href=\"javascript:ShowDialog(1," + dt.Rows[e.Item.ItemIndex]["ID"].ToString() + ")\"><img alt=\"编辑\" src=\"images/ico-edit.gif\" /></a>";
            ltlEdite.Visible = true;
        }

    }

    /// <summary>
    /// 刷新页面
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReset_Click(object sender, EventArgs e)
    {
        InitData();
    }
}